/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2012-2-18
/// Purpose: 		带主键记录集合抽象类定义文件
/// ****************************************************************************
/// Modify By		Date			Remark
/// Robin           2013-1-23       变更Remove方法，使其可以支持transaction
/// ****************************************************************************


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RB.DataAccess;

namespace RB.Domain.RelationalMapping
{
    /// <summary>
    /// 带主键记录集合抽象类
    /// </summary>
    public abstract class KeyedRecordSet<TItem, TKey> : RecordSet<TItem>
        where TItem : class
    {
        /// ****************************************************************************
        #region 自定义方法

        public abstract TItem this[TKey key]
        {
            get;
            set;
        }

        #endregion 自定义方法

        /// ****************************************************************************
        #region 重写KeyedRecordSet方法

        public abstract bool Contains(TItem item);

        public abstract bool Remove(TItem item, Executor exec);

        public bool Remove(TItem item)
        {
            using (Executor exec = DataContext.CreateExecutor())
            {
                return Remove(item, exec);
            }
        }

        #endregion 重写KeyedRecordSet方法
    }
}
